<%--
  Created by IntelliJ IDEA.
  User: 润
  Date: 2021/7/28
  Time: 14:58
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <script type="text/javascript" src="jquery-1.7.2.min.js"></script>
    <script type="text/javascript">
        $(function () {
            $("#insert").click(function () {
                var id=document.getElementById("hidden").value;
                var course=document.getElementById("course").value;
                var place=document.getElementById("place").value;
                var teacher=document.getElementById("teacher").value;
                var time=document.getElementById("time").value;
                var total=document.getElementById("total").value;
                var beginTime=document.getElementById("beginTime").value;
                var gid=document.getElementById("gradeId").value;
                if(course==""||place==""||teacher==""||time==""||total==""||beginTime==""){
                    alert("输入内容不能为空！");
                }else {
                    var para= {

                        action:'queryAllCourse',

                        gid:gid
                    };
                    $.ajax({
                        type: "POST",
                        url: "http://localhost:8080/Anyview/CourseServlet?action=addCourse",
                        data: {"id":id,"course":course,"place":place,"teacher":teacher,"time":time,"total":total,"gid":gid,"beginTime":beginTime},
                        success: function (data) {
                            if (data.result1) {
                                alert("添加成功！");
                                window.location.href = "http://localhost:8080/Anyview/CourseServlet";
                            }
                        },
                        dataType: "json"
                    })
                } })
        })

    </script>
</head>
<body>
<div align="center">
    <form >
        课程:<input type="text" id="course"value="${requestScope.course.name}" ><br>
        地点:<input type="text" id="place" value="${requestScope.course.place}" ><br>
        老师:<input type="text" id="teacher" value="${requestScope.course.teacher}"><br>
        时间:<input type="text" id="time"value="${requestScope.course.TIME}" ><br>
        人数:<input type="text" id="total" value="${requestScope.course.total}" ><br>
        开始时间:<input type="text" id="beginTime" value="${requestScope.course.beginTime}" ><br>
        <input type="hidden"value="${requestScope.course.id}" id="id">
        <input type="button" id="insert" value="确定">
    </form>
</div>

</body>
</html>
